# -*- coding:utf-8 -*-
'''
打开常用网站
'''
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.keys import Keys
#from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains


if __name__ == '__main__':
    # 使用headless无界面浏览器模式
    my_chrome_options = Options()
    #my_chrome_options.add_argument('--headless') #增加无界面选项
    my_chrome_options.add_argument('--disable-gpu') #如果不加这个选项，有时定位会出现问题
    my_chrome_options.add_argument('user-agent="Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36"')
    # 启动浏览器，获取网页源代码 chromedriver.exe放在phantomjs的bin目录下一起加入path变量
    my_serviceDriver = Service(executable_path='chromedriver.exe')
    my_browser = webdriver.Chrome(service=my_serviceDriver,options=my_chrome_options)
    my_browser.maximize_window()
    my_browser.execute_script('window.open("{}","_blank");'.format('https://map.baidu.com/'))
    my_browser.execute_script('window.open("{}","_blank");'.format('https://www.toutiao.com/'))
    ActionChains(my_browser).key_down(Keys.CONTROL).send_keys('t').key_up(Keys.CONTROL).perform()